
#include "dev_err_e2.h"
#include "../res/img_common.h"

int ui_dev_err_e2_create(lv_obj_t *superview,ui_dev_err_e2_t* err_e2)
{
    err_e2->bg_img = lv_img_create(superview);
    #if 0
    lv_img_set_src(err_e2->bg_img,pt_fs_get("BG_shutdown.png"));
    #else
    lv_img_set_src(err_e2->bg_img,&BG_shutdown);
    #endif
    lv_obj_set_pos(err_e2->bg_img,0,0);
    //***************************************************************************
    err_e2->title = lv_label_create(superview);
    lv_obj_set_pos(err_e2->title,108,115);
    lv_obj_set_size(err_e2->title,264,70);
    lv_obj_set_style_text_align(err_e2->title,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(err_e2->title,LV_OPA_80,LV_PART_MAIN);
    lv_obj_set_style_text_color(err_e2->title,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(err_e2->title, lv_font_get(70), LV_STATE_DEFAULT);
    lv_label_set_text( err_e2->title, "E2故障");
    //*****************************************
    err_e2->txt = lv_label_create(superview);
    lv_obj_set_pos(err_e2->txt,0,220);
    lv_obj_set_size(err_e2->txt,480,56);
    lv_obj_set_style_text_align(err_e2->txt,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_opa(err_e2->txt,LV_OPA_40,LV_PART_MAIN);
    lv_obj_set_style_text_color(err_e2->txt,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_obj_set_style_text_font(err_e2->txt, lv_font_get(20), LV_STATE_DEFAULT);
    lv_label_set_text( err_e2->txt, "发热管故障\n请前往APP查看详情或联系客服400-000-000");
    //*****************************************

    return 0;
}

int ui_dev_err_e2_destroy(ui_dev_err_e2_t* err_e2)
{
    if(!err_e2){
        return -1;
    }

    if(err_e2->bg_img){
        lv_obj_del(err_e2->bg_img);
        err_e2->bg_img = NULL;
    }
    if(err_e2->title){
        lv_obj_del(err_e2->title);
        err_e2->title = NULL;
    }
    if(err_e2->txt){
        lv_obj_del(err_e2->txt);
        err_e2->txt = NULL;
    }

    return 0;
}


int ui_dev_err_e2_hide(ui_dev_err_e2_t* err_e2)
{
    if(!err_e2){
        return -1;
    }

    if(err_e2->bg_img){
        lv_obj_add_flag(err_e2->bg_img,LV_OBJ_FLAG_HIDDEN);
    }
    if(err_e2->title){
        lv_obj_add_flag(err_e2->title,LV_OBJ_FLAG_HIDDEN);
    }
    if(err_e2->txt){
        lv_obj_add_flag(err_e2->txt,LV_OBJ_FLAG_HIDDEN);
    }

    return 0;
}

int ui_dev_err_e2_show(ui_dev_err_e2_t* err_e2)
{
    if(!err_e2){
        return -1;
    }

    if(err_e2->bg_img){
        lv_obj_clear_flag(err_e2->bg_img,LV_OBJ_FLAG_HIDDEN);
    }
    if(err_e2->title){
        lv_obj_clear_flag(err_e2->title,LV_OBJ_FLAG_HIDDEN);
    }
    if(err_e2->txt){
        lv_obj_clear_flag(err_e2->txt,LV_OBJ_FLAG_HIDDEN);
    }

    return 0;
}

